package chai.ning.returns;

import java.io.PrintStream;
import java.util.Arrays;

public class Loong {
	public int[] sort(int[] array) {
		int n = array.length;

		int[] newArray = new int[n];
		System.arraycopy(array, 0, newArray, 0, n);

		for (int k = 0; k < n - 1; k++) {
			for (int j = 0; j < n - 1 - k; j++) {
				if (newArray[j] < newArray[(j + 1)]) {
					newArray[j] ^= newArray[(j + 1)];
					newArray[(j + 1)] ^= newArray[j];
					newArray[j] ^= newArray[(j + 1)];
				}
			}

		}

		return newArray;
	}

	public static void main(String[] args) {
		Loong x = new Loong();

		int[] array = { 20, 30, 9, 8, 1, 100, 23 };
		System.out.println("原数组: " + Arrays.toString(array));

		int[] newArray = x.sort(array);
		System.out.println("新数组: " + Arrays.toString(newArray));
		System.out.println("原数组: " + Arrays.toString(array));
	}
}
